home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_asm / astrsys / syskey.asm < prev    next >
Encoding:
Assembly Source File  |  1989-09-25  |  7.1 KB  |  173 lines

  1.                         PAGE    ,132
  2.                         Title   System Key Interface -- TSR
  3.                         .286c
  4.  
  5. ;----------------------------------------------------------------------------;
  6. ; This SysReq Interface file is actually composed of 2 parts.  One part is   ;
  7. ; the Int routine that detects a SysReq Key Depress/Release and the second   ;
  8. ; part being the code that installs this routine as a TSR. Modify the code   ;
  9. ; to your hearts content.  This is simply a way to to it in Assembly.        ;
  10. ;----------------------------------------------------------------------------;
  11.  
  12. ; Include the Dos Calls Equates from this file -- Note only a few are
  13. ; used here, but that include file may prove useful.
  14.  
  15. INCLUDE DOSCALLS.INC
  16.  
  17.  
  18. ; Other Undocumented Stuff... NOT IN DOSCALLS.INC
  19. DosVarCall  EQU 34h     ; Function to get dos busy flag
  20. DosNotBusy  EQU 0h      ; This is =0 when this is!!
  21.  
  22.  
  23. _TEXT  SEGMENT
  24.                 ASSUME cs:_TEXT, ds:_TEXT, ss:_TEXT, es:_TEXT
  25.                 ORG 100H
  26. ENTRY:          Jmp     Install
  27.  
  28.  
  29. Copyright       db      '(C) Copyright 1988, Jovo Systems Incorporate'
  30. Installed       db      'SYSKEY installed.',13,10,'$'
  31. MakeMsg         db      'System Key Request -- MAKE   '
  32. MakeMsgLen      EQU     $-MakeMsg
  33. BreakMsg        db      'System Key Request -- BREAK  '
  34. BreakMsgLen     EQU     $-BreakMsg
  35. UnkMsg          db      'System Key Request -- UNKNOWN'
  36. UnkMsgLen       EQU     $-UnkMsg
  37.  
  38. OldInt15        dd      ?       ; Old address of  int 15
  39. DosBusyAddress  dd      ?       ; Address of where to find if DOS is busy
  40.  
  41.                 PUBLIC  OldInt15
  42.                 PUBLIC  DosBusyAddress
  43.  
  44. SysKeyCode      EQU     85h     ; The code for this
  45. Make            EQU     0h      ; Make code
  46. Break           EQU     1h      ; Break code
  47.  
  48.  
  49.  
  50.  
  51. SysKeyInt       Proc    FAR
  52.                 PUBLIC  SysKeyInt
  53. ;----------------------------------------------------------------------------;
  54. ; This is where INT 15h goes to and we check if key was pressed and such.    ;
  55. ; and thus if not, we jump to the old BIOS routine used otherwise.           ;
  56. ;----------------------------------------------------------------------------;
  57.                 ASSUME  ds:NOTHING      ;
  58.                 Cmp     Ah,SysKeyCode   ; Is key being gener. ?
  59.                 Je      KeyON           ; YES!
  60. OldCall:        Jmp     Cs:[OldInt15]   ;
  61.                                         ;
  62.         KeyON:                          ;
  63.                 Push    Ds              ;
  64.                 Push    Si              ;
  65.                 Lds     Si,cs:DosBusyAddress
  66.                 Cmp     Byte Ptr ds:[si],0
  67.                 Jz      ghead           ;
  68.                 Pop     Si              ;
  69.                 Pop     Ds              ;
  70.                 Jmp     OldCall         ; Call the old int -- DOS BUSY!!
  71.         ghead:                          ;
  72.                 Pop     Si              ;
  73.                 Pop     Ds              ;
  74.                                         ; At This point DOS is not busy
  75.                 Sti                     ;
  76.                 Pusha                   ; Push all
  77.  
  78.                 Push    Es              ;
  79.                                         ;
  80.                 Push    Cs              ;
  81.                 Pop     Es              ;
  82.                                         ;
  83.         Test1:                          ;
  84.                 Cmp     Al,Make         ; Is it a make?
  85.                 Jne     Test2           ; No, Check for break
  86.                                         ;
  87. ; HERE IS WHERE THE SysReq KEY IS DEPRESSED, PROCESSING MAY BEGIN HERE
  88. ; But for now in this TSR, we simple print an anoying message on the screen.
  89.  
  90.                 Mov     Bp,OFFSET MakeMsg
  91.                 Mov     Cx,MakeMsgLen   ;
  92.                 Jmp     Short   PrtM    ;
  93.                                         ;
  94.         Test2:                          ;
  95.                 Cmp     Al,Break        ; Is it a Break?
  96.                 Jne     UnknownKey      ; NO, It is UNKNOWN
  97.                                         ;
  98. ; HERE Is where the SysReq KEY Has Been Released (After Depressing, of course)
  99. ; It is here where you should place your Desired code, i.e.
  100. ; Task Managers (Switchers), Some Utility TSR, or a call to a TSR or
  101. ; if you are daring enough, a menu for all TSR's which selects one to
  102. ; 'pull up'.
  103.                 Mov     Bp, OFFSET BreakMsg
  104.                 Mov     Cx,BreakMsgLen  ;
  105.                 Jmp     Short   PrtM    ;
  106.                                         ;
  107.         UnknownKey:                     ;
  108.                 Mov     Bp, OFFSET UnkMsg
  109.                 Mov     Cx,UnkMsgLen    ;
  110.                                         ;
  111.         PrtM:                           ;
  112.                 Mov     Ax,1300h        ;
  113.                 Mov     Bx,4            ;
  114.                 Mov     Dx,0116h        ;
  115.                 Int     10h             ;
  116.                                         ;
  117.                                         ;
  118.                 Pop     Es              ;
  119.                 Popa                    ;
  120.                 Ret     2               ;
  121. SysKeyInt       Endp
  122.  
  123.  
  124.                 ASSUME  ds:_TEXT
  125.  
  126. Install Proc    Near
  127. ;----------------------------------------------------------------------------;
  128. ; Installs thing and stays resident.                                         ;
  129. ;----------------------------------------------------------------------------;
  130.         ; Set Up our routine to snag the Sys key in interrupt
  131.                 Mov     Ah,DosGetVec    ; Get the vector
  132.                 Mov     Al,15h          ; This
  133.                 Int     DosInt          ;
  134.                 Mov     Word Ptr OldInt15,Bx
  135.                 Mov     Ax,Es
  136.                 Mov     Word Ptr OldInt15+2,Ax
  137.                 Push    Cs
  138.                 Pop     Es
  139.                 Mov     Dx, OFFSET SysKeyInt
  140.                 Mov     Al,15h
  141.                 Mov     Ah,DosSetVec    ;
  142.                 Int     DosInt          ;
  143.  
  144.         ; Get the Address of the Busy flag in DOS
  145.                 Push    Es              ;
  146.                 Push    Bx              ;
  147.                 Mov     Ax,DosVarCall*256   ; The Function
  148.                 Int     DosInt          ; Call Dos
  149.                 Mov     Ax,Es           ;
  150.                 Mov     Word Ptr DosBusyAddress,Bx  ; Save this
  151.                 Mov     Word Ptr DosBusyAddress+2,Ax; And this
  152.                 Pop     Bx              ;
  153.                 Pop     Es              ;
  154.         ; Now, finish Up with a message.......
  155.                 Mov     Dx, OFFSET Installed
  156.                 Mov     Ah,DosPrintString
  157.                 Int     DosInt
  158.                 Mov     Bx,OFFSET Install       ; Get add of this
  159.                 Mov     Ax,Bx           ;
  160.                 Mov     Cl,4            ; Divide by 16
  161.                 Shr     Ax,Cl           ;
  162.                 Inc     Ax              ;
  163.                 Mov     Dx,Ax           ;
  164.                 Mov     Al,0            ;
  165.                 Mov     Ah,DosTSRType1  ;
  166.                 Int     DosInt          ; Bye Bye
  167. Install         Endp
  168.  
  169. _TEXT           ENDS
  170.  
  171.                 END     ENTRY
  172.  
  173.